package p2_6;

import java.util.Random;

public class Project3 {
    public int i = 10;
    public int n = 21;
    public char[] arr = new char[n];
    public char[] originArr = new char[n];

    public static void main(String[] args) {
        Project3 project3 = new Project3();
        project3.prepareArr();
        project3.firstMethod();
        System.out.println(project3.check());
        for (int a : project3.arr)
            System.out.print(a + " ");
        System.out.println();
        for (int b : project3.originArr)
            System.out.print(b + " ");
    }

    public void prepareArr() {
        Random random = new Random();
        for (int j = 0; j < n; j++) {
            arr[j] = (char) random.nextInt(10);
            originArr[j] = arr[j];
        }
    }

    public void firstMethod() {
        char arr0 = arr[0];
        for (int k = 0; k < n - 1; k++) {
            arr[(i * k) % n] = arr[(i * (k + 1)) % n];
        }
        arr[n - i] = arr0;

    }

    public void secondMethod() {
        StringBuffer sb = new StringBuffer();
        for (char c : originArr)
            sb.append(c);


    }


    public boolean check() {
        for (int k = 0; k < n; k++)
            if (arr[(n - i + k) % n] == originArr[k])
                ;
            else
                return false;
        return true;
    }
}